#include <iostream>
#include <vector>

using namespace std;

int main()
{
    string str0,str1;
	cin>>str0>>str1;
	long long a = str0.size(), b=str1.size();
	long long n;
	cin>>n;
	n = n-1;
	long long elozmeny = a+b;
	vector<long long> fibo;
	fibo.push_back(a);
	fibo.push_back(b);
	while(elozmeny < n) {
		fibo.push_back (fibo[fibo.size()-2] + fibo[fibo.size()-1]);
		elozmeny += fibo[fibo.size()-1];
	}
	elozmeny = elozmeny - fibo[fibo.size()-1];
	n = n - elozmeny;
	int akt = fibo.size()-1;
	while(akt!=0 && akt!=1) {
		if (n < fibo[akt-2]) {
			akt = akt-2;
		}
		else {
			n = n - fibo[akt-2];
			akt = akt-1;
		}
	}

	if(akt==0)
		cout<<str0[n];
	else
		cout<<str1[n];
}